import os

sourcepath = r"d:\\DIFF"
oldexcelsave = sourcepath + r'\\oldxls'
newexcelsave = sourcepath + r'\\newxls'
oldtxtsave = sourcepath + r'\\oldtxt'
newtxtsave = sourcepath + r'\\newtxt'
localdatapath = sourcepath + r'\\localdata.json'
server_path = r"d:\\localserver"
server_info_path = server_path + r'\\publishoutput'


def init_server_path():
    if not os.path.exists(server_path):
        os.mkdir(server_path)
    if not os.path.exists(server_path + r'\\publishoutput'):
        os.mkdir(server_info_path)


def init_excel_dir():
    if not os.path.exists(sourcepath):
        os.mkdir(sourcepath)
    if not os.path.exists(oldexcelsave):
        os.mkdir(oldexcelsave)
    if not os.path.exists(newexcelsave):
        os.mkdir(newexcelsave)
    cleardir(oldexcelsave)
    cleardir(newexcelsave)


def init_txt_dir(target: str):
    if not os.path.exists(sourcepath):
        os.mkdir(sourcepath)
    if not os.path.exists(target):
        os.mkdir(target)
    cleardir(target)


def cleardir(path: str):
    files = os.listdir(path)
    for file in files:
        os.remove(os.path.join(path, file))
